<template>
  <li>
    <img :src="item.img" alt="" />
    <h6>{{ item.desc }}</h6>
    <h5>
      <span>{{ item.name }}</span> <button @click="add">+</button>
    </h5>
  </li>
</template>

<script>
export default {
  props: ["item"],
  data() {
    return {};
  },
  created() {},
  methods: {
    add() {
      this.$store.commit("add", this.item);
      //传的数据是props里的数据 props的用法跟data一样
    },
  },
  components: {},
};
</script>

<style lang="scss"></style>
